import Vue from "vue";
import VueRouter from "vue-router"
import peopleMessage from "../../vue/views/peopleMessage";

Vue.use(VueRouter)

const routes = [
    // 配置路由重定向
    {
      path: '/',
      redirect: '/home'
  },
  {
    path: '/',
    name: 'Main',
    component: () => import('../views/Main'),
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('../views/home')
      },
      {
        // path: '/accountManage',
        // name: 'accountManage',
        // component: () => import('../views/accountManage/index'),
        // children: [
          // {
            path: 'studentMessage',
            name: 'studentMessage',
            component:()=>import('../views/accountManage/studentMessage/index.vue'),
          },
          {
            path: 'teacherManage',
            name: 'teacherManage',
            component:()=>import('../views/accountManage/teacherManage/index.vue'),
          },
        // ]
      // },
      {
        path: '/questionManage',
        name: 'questionManage',
        component: () => import('../views/questionManage/index.vue')
      },
      {
        path: '/testManage',
        name: 'testManage',
        component: () => import('../views/testManage/index.vue')
      },
      {
        path: '/subjectManage',
        name: 'subjectManage',
        component: () => import('../views/subjectManage/index.vue')
      },
      {
        path: '/peopleMessage',
        name: 'peopleMessage',
        component: peopleMessage,
        children: [
          {
            path: 'message1',
            name: 'message1',
            component:()=>import('../views/peopleMessage/views/message1.vue')
          },
          {
            path: 'message2',
            name: 'message2',
            component:()=>import('../views/peopleMessage/views/message2.vue')
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login')
  }
]

const router = new VueRouter({
  mode: "history",
  routes
})
//重写push方法，防止重复点击报错
const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {

   return originalPush.call(this, location).catch(err => err)
}

export default router
